﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VINETLIFE.BL;
using VINETLIFE.DO;

namespace VINETLIFE.Module
{
    public partial class ucHeader : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                ltrSlogan.Text = new sysConfigBL().Select(new sysConfigDO() { ConfigID = 27 }).ConfigValue;
                ltrSloganUnderLogo.Text = new sysConfigBL().Select(new sysConfigDO() { ConfigID = 28 }).ConfigValue;
                ltrHotline.Text = new sysConfigBL().Select(new sysConfigDO() { ConfigID = 30 }).ConfigValue;
                h1web.InnerText = new sysConfigBL().Select(new sysConfigDO() { ConfigID = 1 }).ConfigValue;
            }
            rptMainMenuDataSource();
            rptHeaderTagDataSource();
            if (Session["FullName"] != null)
            {
                pnwelcome.Visible = true;
                pnLogin.Visible = false;
                lblUserName.Text = Session["FullName"].ToString();
            }
            else
            {
                pnLogin.Visible = true;
                pnwelcome.Visible = false;
            }

        }
        private void rptHeaderTagDataSource()
        {
            rptHeaderTag.DataSource = new cmsTagBL().GetByType(6, 1);
            rptHeaderTag.DataBind();
        }
        private void rptMainMenuDataSource()
        {
            rptMainMenu.DataSource = new cmsMenuBL().SelectMenu(1, 0);
            rptMainMenu.DataBind();
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (!search.Text.Trim().Equals(""))
            {
                string keyword = search.Text.Trim().Replace(" ", "-");
                Response.Redirect("/Search.aspx?keyword=" + keyword);
            }
        }

        protected void btnLogout_Click(object sender, EventArgs e)
        {
            Session["FullName"] = null;
            Session["CustomerID"] = null;
            Response.Redirect(Request.Url.AbsolutePath);
        }
    }
}